FROM golang:1.17 AS build
WORKDIR /httpserver/
COPY . .
ENV CGO_ENABLED=0
ENV GO111MODULE=on
ENV GOPROXY=https://goproxy.cn,direct
RUN go mod init gitee.com/go_task && \
  go mod tidy
RUN GOOS=linux go get github.com/golang/glog
RUN GOOS=linux go get github.com/prometheus/client_golang/prometheus/promhttp
RUN GOOS=linux go build -o httpserver main.go

FROM busybox
COPY --from=build /httpserver/httpserver /httpserver/httpserver
EXPOSE 80
ENV ENV local
WORKDIR /httpserver/
ENTRYPOINT ["./httpserver"]